package com.yuan.hospital.common.utils;

import com.yuan.hospital.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取当前用户信息工具类
 * @Author yuan
 * @Date 2021/7/12 16:45
*/
public class AuthContextHolder {
    /**
     * 获取当前用户id
     * @param request
     * @return
     */
    public static Long getUserId(HttpServletRequest request){
        String token = request.getHeader("token");
        return JwtHelper.getUserId(token);
    }

    /**
     * 取当前用户名称
     * @param request
     * @return
     */
    public static String getUserName(HttpServletRequest request){
        String token = request.getHeader("token");
        return JwtHelper.getUserName(token);
    }
}
